#include "GLHeaders.hpp"
#include "ReferenceFrame.hpp"

void ReferenceFrame_::Draw(void)const{
	glCallList(list_id);
}

ReferenceFrame_::ReferenceFrame_(void){
	list_id = glGenLists(1); // create one DisplayList
	glNewList(list_id, GL_COMPILE);
	glPushAttrib(GL_COLOR_BUFFER_BIT|GL_CURRENT_BIT|GL_TEXTURE_BIT);	
	glDisable(GL_TEXTURE_2D);
	glBegin(GL_LINES);
	glColor3f(1.0f, 0.0f, 0.0f); // X axe (Red)
	glVertex3f(0.0f, 0.0f, 0.0f);
	glVertex3f(1.0f, 0.0f, 0.0f);

	glVertex3f( 1.0f, 0.0f, 0.0f);  
	glVertex3f( 0.9f, 0.05f, 0.0f);  
	glVertex3f( 1.0f, 0.0f, 0.0f);  
	glVertex3f( 0.9f,-0.05f, 0.0f);    
	glVertex3f( 1.0f, 0.0f, 0.0f);  
	glVertex3f( 0.9f, 0.0f, 0.05f);  
	glVertex3f( 1.0f, 0.0f, 0.0f);  
	glVertex3f( 0.9f, 0.0f,-0.05f);  

	glColor3f(0.0f, 1.0f, 0.0f); // Y axe (Green)
	glVertex3f(0.0f, 0.0f, 0.0f);
	glVertex3f(0.0f, 1.0f, 0.0f);

	glVertex3f( 0.0f, 1.0f, 0.0f);  
	glVertex3f( 0.05f, 0.9f, 0.0f);  
	glVertex3f( 0.0f, 1.0f, 0.0f);  
	glVertex3f(-0.05f, 0.9f, 0.0f);  
	glVertex3f( 0.0f, 1.0f, 0.0f);  
	glVertex3f( 0.0f, 0.9f, 0.05f);  
	glVertex3f( 0.0f, 1.0f, 0.0f);  
	glVertex3f( 0.0f, 0.9f,-0.05f);  

	glColor3f(0.0f, 0.0f, 1.0f); // Z axe (Blue)
	glVertex3f(0.0f, 0.0f, 0.0f);
	glVertex3f(0.0f, 0.0f, 1.0f);

	glVertex3f( 0.0f, 0.0f, 1.0f);  
	glVertex3f( 0.05f, 0.0f, 0.9f);  
	glVertex3f( 0.0f, 0.0f, 1.0f);  
	glVertex3f(-0.05f, 0.0f, 0.9f);  
	glVertex3f( 0.0f, 0.0f, 1.0f);  
	glVertex3f( 0.0f, 0.05f, 0.9f);  
	glVertex3f( 0.0f, 0.0f, 1.0f);  
	glVertex3f( 0.0f,-0.05f, 0.9f);  
	glEnd();
	glPopAttrib();
	glEndList();
}

ReferenceFrame_::~ReferenceFrame_(void){
	glDeleteLists(list_id,1);
}
